package com.wimcorp.magic.behaviour.attack;

import com.wimcorp.magic.cards.Creature;
import com.wimcorp.magic.players.Player;

public class DefaultAttack extends AttackBehaviour {

	private static DefaultAttack instance = new DefaultAttack();

	protected DefaultAttack() {

	}

	public DefaultAttack(Creature creature, AttackBehaviour attackBehaviour) {
		super(creature, attackBehaviour);
	}

	public DefaultAttack(Creature creature) {
		super(creature, null);
	}

	public static DefaultAttack instance() {
		return instance;
	}

	protected void attack(Creature defender) {
		String message = getCreature().getName() + " does " + getCreature().getActualPower() + " damage to "
				+ defender.getName();
		defender.getPlayer().message(message);
		defender.getPlayer().messageOpponent(message);
		getCreature().setActualPower(defender.subtractLife(getCreature().getActualPower()));
	}

	public void counter(Creature attacker) {
		String message = getCreature().getName() + " does " + getCreature().getActualPower() + " damage to "
				+ attacker.getName();
		attacker.getPlayer().message(message);
		attacker.getPlayer().messageOpponent(message);
		getCreature().setActualPower(attacker.subtractLife(getCreature().getActualPower()));
	}

	protected void attack(Player defender) {
		String message = getCreature().getName() + " does " + getCreature().getActualPower() + " damage to "
				+ defender.getName();
		defender.message(message);
		defender.messageOpponent(message);
		defender.subtractLife(getCreature().getActualPower());
		getCreature().setActualPower(0);
	}

	public String toString() {
		return "Normal attack";
	}

	public int priority() {
		return AttackType.DEFAULTATTACK.ordinal();
	}

	public boolean equals(Object o) {
		return o instanceof DefaultAttack;
	}

}
